package common.network.eolo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.util.ArrayList;

import common.log.WindLog;
import common.network.BasicURL;

public class EoloURL extends BasicURL {

	private ArrayList<String> dataFromEolo;

	public ArrayList<String> getContent() throws IOException {
		if (myURL != null) {
			dataFromEolo.clear();
			WindLog.getLogger().logInfo("Start connection to " + myURL.getHost());
			
			BufferedReader in = new BufferedReader(new InputStreamReader(myURL
					.openStream()));

			String inputLine;

			while ((inputLine = in.readLine()) != null) {
				if ((!inputLine.contains("DATA"))
						&& (!inputLine.trim().equals("")))
					dataFromEolo.add(inputLine);
			}
			in.close();
			
			WindLog.getLogger().logInfo("End connection");
		}

		return dataFromEolo;
	}

	public EoloURL(String aUrl) throws MalformedURLException {
		super(aUrl);
		dataFromEolo = new ArrayList<String>();
	}

}
